const config = require("../../mfo.config");
const t = require("../../config/dict");
const { fetchRemote } = require("../utils");
const path = require("path");
const rm = require("rimraf");

module.exports = (context) => {
  const dir = path.resolve(__dirname, "../../baseTemplate");
  return new Promise((resolve, reject) => {
    rm(dir, (err) => {
      /* if (err) {
        return;
      } */
      const url = "direct:" + config.template.default;
      fetchRemote(url, dir, context, [
        t(context.lang, "拉取远程模板"),
        ",",
        t(context.lang, "请稍候"),
      ])
        .then((context) => {
          resolve(context);
        })
        .catch((err) => {
          reject(err);
        });
    });
  });
};
